<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue中的列表过渡</title>
    <script src="./vue.js"></script>
    <style>
        .v-enter, .v-leave-to {
            opacity: 0;
        }
        .v-enter-active, .v-leave-active {
            transition: opacity 1s;
        }
    </style>
</head>
<body>

    <div id="root">
        <transition-group>
             <!-- 这里尽量不使用index作为key -->
            <div v-for="(item, index) of list" :key="item.id">
                {{item.title}}
            </div>
        </transition-group>
        
        <button @click="handleBtnClick">Add</button>
    </div>

    <script>
        var count = 0;
        var vm = new Vue({
            el: "#root",
           data:{
               list: []
           },
           methods: {
            handleBtnClick () {
                this.list.push({
                    id:count++,
                    title: 'hello world'+" "+ count
                })
            }
           }
        })
    </script>
</body>
</html>